<?php
	include_once 'isLogin.php';
	$servicec=new service(); //服务类

	$state= array('stay' =>'等待','pass' =>'通过', 'refuse' =>'拒绝');
	$table_name="zs_service";			//服务
	$table_album="zs_service_album";//相册


	//删除
	if($_GET['action']=='del'){
		$delFile = array(
				array('key'=>'logo','dir'=>'../upload/service/large/'),
				array('key'=>'logo','dir'=>'../upload/service/small/'),
				array('key'=>'qr_code','dir'=>'../upload/service/large/'),
				array('key'=>'qr_code','dir'=>'../upload/service/small/'),
			);
		$commonc->del($table_name,$_POST['id'],$delFile);

		$delFile = array(
				array('key'=>'img','dir'=>'../upload/service/large/'),
				array('key'=>'img','dir'=>'../upload/service/small/'),
			);
		//删除相册
		echo $commonc->del($table_album,$_POST['id'],$delFile,'service_id');
		exit();
	}


	//搜索
	if($_POST){
		$where=" AND s.title like '%".$_POST['title']."%'";
		$smarty->assign('search',$_POST);
	}

	//列表
	$row=$servicec->service_list($where);
	$page=$row['page'];
	$row=$row['result'];

	for ($i=0; $i <count($row) ; $i++) { 
		$row[$i]['create_time']=date('Y-m-d H:i:s',$row[$i]['create_time']);
		$row[$i]['state_name']=$state[$row[$i]['check']];
	}


	$smarty->assign("row",$row);
	$smarty->assign('page',$page);

	
	$smarty->display("service_list.html");
?>